using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace DIS_BUS_WS
{
    #region Using

    using DIS_BUS_WS.DIS_DAL_WS;
    using DIS_BUS_WS.Helpers;
    using System.Web.Hosting;
    using System.IO;
    
    #endregion

    public class DIS_BUS_Service: IDIS_BUS_Service
    {
        #region Variables

        private IDIS_DAL_Service _svc;
        
        #endregion

        #region Constructors

        public DIS_BUS_Service()
		{
			_svc = new ChannelFactory<IDIS_DAL_Service>("BasicHttpBinding_IDIS_DAL_Service").CreateChannel();
		}

        #endregion

        #region CATEGORY
        
		public CategoryDTO[] Category_SelectAll()
		{
			return _svc.Category_SelectAll();
		}
		public CategoryDTO Category_SelectByID(int id)
		{
			return _svc.Category_SelectByID(id);
		}
		public bool Category_Insert(CategoryDTO obj)
		{
			return _svc.Category_Insert(obj);
		}
		public bool Category_Delete(int id)
		{
			return _svc.Category_Delete(id);
		}
		public bool Category_Update(CategoryDTO obj)
		{
			return _svc.Category_Update(obj);
		}
		public CategoryDTO[] Category_RetrieveByID(int id)
		{
			return _svc.Category_RetrieveByID(id);
		}

        #endregion

        #region DAILYREPORT
        
		public DailyReportDTO[] DailyReport_SelectAll()
		{
			return _svc.DailyReport_SelectAll();
		}
		public DailyReportDTO DailyReport_SelectByID(int id)
		{
			return _svc.DailyReport_SelectByID(id);
		}
		public bool DailyReport_Insert(DailyReportDTO obj)
		{
			return _svc.DailyReport_Insert(obj);
		}
		public bool DailyReport_Delete(int id)
		{
			return _svc.DailyReport_Delete(id);
		}
		public bool DailyReport_Update(DailyReportDTO obj)
		{
			return _svc.DailyReport_Update(obj);
		}
		public DailyReportDTO[] DailyReport_RetrieveByID(int id)
		{
			return _svc.DailyReport_RetrieveByID(id);
		}
		public DailyReportDTO[] DailyReport_SelectByIDChemistWareHouse(int idChemistWareHouse)
		{
			return _svc.DailyReport_SelectByIDChemistWareHouse(idChemistWareHouse);
		}
        public DailyReportDTO DailyReport_SelectByIDChemistWareHouseAndReportDate(int idChemistWareHouse, DateTime reportdate)
        {
            return _svc.DailyReport_SelectByIDChemistWareHouseAndReportDate(idChemistWareHouse, reportdate);
        }

        #endregion

        #region WEEKLYREPORT
        
		public WeeklyReportDTO[] WeeklyReport_SelectAll()
		{
			return _svc.WeeklyReport_SelectAll();
		}
		public WeeklyReportDTO WeeklyReport_SelectByID(int id)
		{
			return _svc.WeeklyReport_SelectByID(id);
		}
		public bool WeeklyReport_Insert(WeeklyReportDTO obj)
		{
			return _svc.WeeklyReport_Insert(obj);
		}
		public bool WeeklyReport_Delete(int id)
		{
			return _svc.WeeklyReport_Delete(id);
		}
		public bool WeeklyReport_Update(WeeklyReportDTO obj)
		{
			return _svc.WeeklyReport_Update(obj);
		}
		public WeeklyReportDTO[] WeeklyReport_RetrieveByID(int id)
		{
			return _svc.WeeklyReport_RetrieveByID(id);
		}
		public WeeklyReportDTO[] WeeklyReport_SelectByIDChemistWareHouse(int idChemistWareHouse)
		{
			return _svc.WeeklyReport_SelectByIDChemistWareHouse(idChemistWareHouse);
		}
        public WeeklyReportDTO WeeklyReport_SelectByIDChemistWareHouseAndReportDate(int idChemistWareHouse, DateTime startdate, DateTime enddate)
        {
            return _svc.WeeklyReport_SelectByIDChemistWareHouseAndReportDate(idChemistWareHouse, startdate, enddate);
        }

        #endregion

        #region ITEM
        
		public ItemDTO[] Item_SelectAll()
		{
			return _svc.Item_SelectAll();
		}
		public ItemDTO Item_SelectByID(int id)
		{
			return _svc.Item_SelectByID(id);
		}
		public bool Item_Insert(ItemDTO obj)
		{
			return _svc.Item_Insert(obj);
		}
		public bool Item_Delete(int id)
		{
			return _svc.Item_Delete(id);
		}
		public bool Item_Update(ItemDTO obj)
		{
			return _svc.Item_Update(obj);
		}
		public ItemDTO[] Item_RetrieveByID(int id)
		{
			return _svc.Item_RetrieveByID(id);
		}
		public ItemDTO[] Item_SelectByIDCategory(int idcategory)
		{
			return _svc.Item_SelectByIDCategory(idcategory);
		}

        public bool Item_UploadFile(string fileName, byte[] buffer, string oldname = "")
        {
            return _svc.Item_UploadFile(fileName, buffer, oldname);
        }

        public byte[] Item_DownloadFile(string fileName)
        {
            return _svc.Item_DownloadFile(fileName);
        }

        #endregion

        #region EMPLOYEE
        
		public EmployeeDTO[] Employee_SelectAll()
		{
			return _svc.Employee_SelectAll();
		}
		public EmployeeDTO Employee_SelectByID(int id)
		{
			return _svc.Employee_SelectByID(id);
		}
		public bool Employee_Insert(EmployeeDTO obj)
		{
			return _svc.Employee_Insert(obj);
		}
		public bool Employee_Delete(int id)
		{
			return _svc.Employee_Delete(id);
		}
		public bool Employee_Update(EmployeeDTO obj)
		{
			return _svc.Employee_Update(obj);
		}
		public EmployeeDTO[] Employee_RetrieveByID(int id)
		{
			return _svc.Employee_RetrieveByID(id);
		}
		public EmployeeDTO[] Employee_SelectByIDRole(int idrole)
		{
			return _svc.Employee_SelectByIDRole(idrole);
		}
		public EmployeeDTO[] Employee_SelectByIDChemistWareHouse(int idChemistWareHouse)
		{
			return _svc.Employee_SelectByIDChemistWareHouse(idChemistWareHouse);
		}
        public EmployeeDTO Employee_SelectByUserName(string username)
        {
            return _svc.Employee_SelectByUserName(username);
        }
        public EmployeeDTO Employee_SelectByUserNameAndPassword(string username, string password)
        {
            return _svc.Employee_SelectByUserNameAndPassword(username, password);
        }

        #endregion

        #region NATIONALPROMOTION
        
		public NationalPromotionDTO[] NationalPromotion_SelectAll()
		{
			return _svc.NationalPromotion_SelectAll();
		}
		public NationalPromotionDTO NationalPromotion_SelectByID(int id)
		{
			return _svc.NationalPromotion_SelectByID(id);
		}
		public bool NationalPromotion_Insert(NationalPromotionDTO obj)
		{
			return _svc.NationalPromotion_Insert(obj);
		}
		public bool NationalPromotion_Delete(int id)
		{
			return _svc.NationalPromotion_Delete(id);
		}
		public bool NationalPromotion_Update(NationalPromotionDTO obj)
		{
			return _svc.NationalPromotion_Update(obj);
		}
		public NationalPromotionDTO[] NationalPromotion_RetrieveByID(int id)
		{
			return _svc.NationalPromotion_RetrieveByID(id);
		}
		public NationalPromotionDTO NationalPromotion_SelectByIDItem(int iditem)
		{
			return _svc.NationalPromotion_SelectByIDItem(iditem);
		}

        #endregion

        #region LOCALPROMOTION
        
		public LocalPromotionDTO[] LocalPromotion_SelectAll()
		{
			return _svc.LocalPromotion_SelectAll();
		}
		public LocalPromotionDTO LocalPromotion_SelectByID(int id)
		{
			return _svc.LocalPromotion_SelectByID(id);
		}
		public bool LocalPromotion_Insert(LocalPromotionDTO obj)
		{
			return _svc.LocalPromotion_Insert(obj);
		}
		public bool LocalPromotion_Delete(int id)
		{
			return _svc.LocalPromotion_Delete(id);
		}
        public bool LocalPromotion_DeleteByIDItemAndIDChemistWareHouse(int iditem, int idChemistWareHouse)
        {
            return _svc.LocalPromotion_DeleteByIDItemAndIDChemistWareHouse(iditem, idChemistWareHouse);
        }
		public bool LocalPromotion_Update(LocalPromotionDTO obj)
		{
			return _svc.LocalPromotion_Update(obj);
		}
		public LocalPromotionDTO[] LocalPromotion_RetrieveByID(int id)
		{
			return _svc.LocalPromotion_RetrieveByID(id);
		}
		public LocalPromotionDTO[] LocalPromotion_SelectByIDItem(int iditem)
		{
			return _svc.LocalPromotion_SelectByIDItem(iditem);
		}
		public LocalPromotionDTO[] LocalPromotion_SelectByIDChemistWareHouse(int idChemistWareHouse)
		{
			return _svc.LocalPromotion_SelectByIDChemistWareHouse(idChemistWareHouse);
		}
        public LocalPromotionDTO LocalPromotion_SelectByIDItemAndIDChemistWareHouse(int iditem, int idChemistWareHouse)
        {
            return _svc.LocalPromotion_SelectByIDItemAndIDChemistWareHouse(iditem, idChemistWareHouse);
        }

        #endregion

        #region ORDERS
        
		public OrdersDTO[] Orders_SelectAll()
		{
			return _svc.Orders_SelectAll();
		}
		public OrdersDTO Orders_SelectByID(int id)
		{
			return _svc.Orders_SelectByID(id);
		}
		public bool Orders_Insert(ref OrdersDTO obj)
		{
			return _svc.Orders_Insert(ref obj);
		}
		public bool Orders_Delete(int id)
		{
			return _svc.Orders_Delete(id);
		}
		public bool Orders_Update(OrdersDTO obj)
		{
			return _svc.Orders_Update(obj);
		}
		public OrdersDTO[] Orders_RetrieveByID(int id)
		{
			return _svc.Orders_RetrieveByID(id);
		}
		public OrdersDTO[] Orders_SelectByIDChemistWareHouse(int idChemistWareHouse)
		{
            try
            {
                return _svc.Orders_SelectByIDChemistWareHouse(idChemistWareHouse);
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    GlobalVariables.Logger.Error(ex.InnerException.Message);
                }
                else
                {
                    GlobalVariables.Logger.Error(ex.Message);
                }
            }
            return null;
		}
        public OrdersDTO[] Orders_SelectByIDChemistWareHouseAndOrderDate(int idChemistWareHouse, DateTime orderdate)
        {
            return _svc.Orders_SelectByIDChemistWareHouseAndOrderDate(idChemistWareHouse, orderdate);
        }

        public OrdersDTO[] Orders_SelectByIDCustomer(int idcustomer)
        {
            return _svc.Orders_SelectByIDCustomer(idcustomer);
        }

        #endregion

        #region ORDERDETAIL
        
		public OrderDetailDTO[] OrderDetail_SelectAll()
		{
			return _svc.OrderDetail_SelectAll();
		}
		public OrderDetailDTO OrderDetail_SelectByID(int id)
		{
			return _svc.OrderDetail_SelectByID(id);
		}
		public bool OrderDetail_Insert(OrderDetailDTO obj)
		{
			return _svc.OrderDetail_Insert(obj);
		}
		public bool OrderDetail_Delete(int id)
		{
			return _svc.OrderDetail_Delete(id);
		}
        public bool OrderDetail_DeleteByOrder(int idorder)
        {
            return _svc.OrderDetail_DeleteByOrder(idorder);
        }
		public bool OrderDetail_Update(OrderDetailDTO obj)
		{
			return _svc.OrderDetail_Update(obj);
		}
		public OrderDetailDTO[] OrderDetail_RetrieveByID(int id)
		{
			return _svc.OrderDetail_RetrieveByID(id);
		}
		public OrderDetailDTO[] OrderDetail_SelectByIDOrder(int idorder)
		{
			return _svc.OrderDetail_SelectByIDOrder(idorder);
		}
		public OrderDetailDTO[] OrderDetail_SelectByIDItem(int iditem)
		{
			return _svc.OrderDetail_SelectByIDItem(iditem);
		}

        #endregion

        #region ROLEFUNCTIONS
        
		public RoleFunctionsDTO[] RoleFunctions_SelectAll()
		{
			return _svc.RoleFunctions_SelectAll();
		}
		public RoleFunctionsDTO RoleFunctions_SelectByID(int id)
		{
			return _svc.RoleFunctions_SelectByID(id);
		}
		public bool RoleFunctions_Insert(RoleFunctionsDTO obj)
		{
			return _svc.RoleFunctions_Insert(obj);
		}
		public bool RoleFunctions_Delete(int id)
		{
			return _svc.RoleFunctions_Delete(id);
		}
		public bool RoleFunctions_Update(RoleFunctionsDTO obj)
		{
			return _svc.RoleFunctions_Update(obj);
		}
		public RoleFunctionsDTO[] RoleFunctions_RetrieveByID(int id)
		{
			return _svc.RoleFunctions_RetrieveByID(id);
		}
		public RoleFunctionsDTO[] RoleFunctions_SelectByIDRole(int idrole)
		{
			return _svc.RoleFunctions_SelectByIDRole(idrole);
		}
		public RoleFunctionsDTO[] RoleFunctions_SelectByIDFunction(int idfunction)
		{
			return _svc.RoleFunctions_SelectByIDFunction(idfunction);
		}

        #endregion

        #region FUNCTIONS
        
		public FunctionsDTO[] Functions_SelectAll()
		{
			return _svc.Functions_SelectAll();
		}
		public FunctionsDTO Functions_SelectByID(int id)
		{
			return _svc.Functions_SelectByID(id);
		}
		public bool Functions_Insert(FunctionsDTO obj)
		{
			return _svc.Functions_Insert(obj);
		}
		public bool Functions_Delete(int id)
		{
			return _svc.Functions_Delete(id);
		}
		public bool Functions_Update(FunctionsDTO obj)
		{
			return _svc.Functions_Update(obj);
		}
		public FunctionsDTO[] Functions_RetrieveByID(int id)
		{
			return _svc.Functions_RetrieveByID(id);
		}

        #endregion

        #region ROLE
        
		public RoleDTO[] Role_SelectAll()
		{
			return _svc.Role_SelectAll();
		}
		public RoleDTO Role_SelectByID(int id)
		{
			return _svc.Role_SelectByID(id);
		}
		public bool Role_Insert(RoleDTO obj)
		{
			return _svc.Role_Insert(obj);
		}
		public bool Role_Delete(int id)
		{
			return _svc.Role_Delete(id);
		}
		public bool Role_Update(RoleDTO obj)
		{
			return _svc.Role_Update(obj);
		}
		public RoleDTO[] Role_RetrieveByID(int id)
		{
			return _svc.Role_RetrieveByID(id);
		}

        #endregion

        #region CHEMIST WAREHOUSE

        public ChemistWareHouseDTO[] ChemistWareHouse_SelectAll()
		{
			return _svc.ChemistWareHouse_SelectAll();
		}
		public ChemistWareHouseDTO ChemistWareHouse_SelectByID(int id)
		{
			return _svc.ChemistWareHouse_SelectByID(id);
		}
		public bool ChemistWareHouse_Insert(ChemistWareHouseDTO obj)
		{
			return _svc.ChemistWareHouse_Insert(obj);
		}
		public bool ChemistWareHouse_Delete(int id)
		{
			return _svc.ChemistWareHouse_Delete(id);
		}
		public bool ChemistWareHouse_Update(ChemistWareHouseDTO obj)
		{
			return _svc.ChemistWareHouse_Update(obj);
		}
		public ChemistWareHouseDTO[] ChemistWareHouse_RetrieveByID(int id)
		{
			return _svc.ChemistWareHouse_RetrieveByID(id);
        }

        #endregion

        #region CUSTOMER

        public CustomerDTO[] Customer_SelectAll()
        {
            return _svc.Customer_SelectAll();
        }
        public CustomerDTO Customer_SelectByID(int id)
        {
            return _svc.Customer_SelectByID(id);
        }
        public bool Customer_Insert(CustomerDTO obj)
        {
            return _svc.Customer_Insert(obj);
        }
        public bool Customer_Delete(int id)
        {
            return _svc.Customer_Delete(id);
        }
        public bool Customer_Update(CustomerDTO obj)
        {
            return _svc.Customer_Update(obj);
        }
        public CustomerDTO[] Customer_RetrieveByID(int id)
        {
            return _svc.Customer_RetrieveByID(id);
        }

        public CustomerDTO Customer_SelectByUserName(string username)
        {
            return _svc.Customer_SelectByUserName(username);
        }

        public CustomerDTO Customer_SelectByUserNameAndPassword(string username, string password)
        {
            return _svc.Customer_SelectByUserNameAndPassword(username, password);
        }

        #endregion

        #region CART

        public CartDTO[] Cart_SelectByCartID(string cartid)
        {
            return _svc.Cart_SelectByCartID(cartid);
        }
        public CartDTO Cart_SelectByIDAndRecordID(string cartid, string recordid)
        {
            return _svc.Cart_SelectByIDAndRecordID(cartid, recordid);
        }
        public CartDTO Cart_SelectByRecordID(string recordid)
        {
            return _svc.Cart_SelectByRecordID(recordid);
        }
        public CartDTO Cart_SelectByIDAndItem(string cartid, string foodid)
        {
            return _svc.Cart_SelectByIDAndItem(cartid, foodid);
        }
        public bool Cart_Insert(CartDTO obj)
        {
            return _svc.Cart_Insert(obj);
        }
        public bool Cart_Delete(string cartid, string recordid)
        {
            return _svc.Cart_Delete(cartid, recordid);
        }
        public bool Cart_Empty(string cartid)
        {
            return _svc.Cart_Empty(cartid);
        }
        public bool Cart_Update(CartDTO obj)
        {
            return _svc.Cart_Update(obj);
        }

        #endregion
    }
}
